package com.audaque.springboot.foshanupload.shardingsphere.config;

import io.shardingsphere.api.algorithm.sharding.PreciseShardingValue;
import io.shardingsphere.api.algorithm.sharding.standard.PreciseShardingAlgorithm;
import lombok.extern.slf4j.Slf4j;

import java.util.Collection;

@Slf4j
public class ShardingDatabaseStrategy implements PreciseShardingAlgorithm<String> {
    public ShardingDatabaseStrategy() {
    }

    @Override
    public String doSharding(Collection<String> databaseNames, PreciseShardingValue<String> preciseShardingValue) {
        int n = preciseShardingValue.getValue().equals("a") ? 0 : 1;
        return "ds" + n;
//        throw new UnsupportedOperationException();
    }
}
